﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.BizTalk.ExplorerOM;
using DBLOG.BizTalk.BizTalkExplorerServices.Core;

namespace DBLOG.BizTalk.BizTalkExplorerServices.Entities
{
    public class BTSSendPort : BTSPortBase
    {
        private SendPort _sendPort { get; set; }

        public BTSSendPort()
        {
        }

        internal BTSSendPort(SendPort sendPort)
        {
            this._sendPort = sendPort;

            this.PopulateSimpleProperties();
        }

        private void PopulateSimpleProperties()
        {
            this.Name = _sendPort.Name;

            this.ApplicationName = _sendPort.Application.Name;

            switch (this._sendPort.Status)
            {
                case PortStatus.Started:
                    this.Status = Core.Status.Started;
                    break;
                case PortStatus.Stopped:
                    this.Status = Core.Status.Stopped;
                    break;
            }

            if (this._sendPort.PrimaryTransport != null)
            {
                this.TransportProtocol = _sendPort.PrimaryTransport.TransportType.Name;

                this.TransportAddress = _sendPort.PrimaryTransport.Address;
            }
        }
    }
}
